package com.sywb.chuangyebao.view.fragment;

import android.os.Bundle;
import android.view.View;

import com.sywb.chuangyebao.contract.NewsContract;

import java.io.Serializable;

/**
 * 首页-资讯文章
 */
public class NewsFragment extends BaseRefreshFragment<NewsContract.Presenter> implements NewsContract.View {

    private int uid;//资讯文章发布者ID -1:所有发布者 用户ID,可用-1代表不限制 0:创业万里行

    /**
     * Fragment 实例
     */
    public static NewsFragment newInstance(Object... pramars) {
        NewsFragment fragment = new NewsFragment();
        fragment.setArguments(getBundle(pramars));
        return fragment;
    }

    @Override
    public void initView(View view, Bundle bundle) {
        super.initView(view, bundle);
        if (bundle == null) {
            uid = getArguments().getInt("p0", -1);
        } else {
            uid = bundle.getInt("p0", -1);
        }
    }

    @Override
    public void initPresenter() {
        mPresenter.initPresenter(this);
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        outState.putInt("p0", uid);
        super.onSaveInstanceState(outState);
    }

    @Override
    public String getStatisticsIdentity() {
        if (uid < 0) {
            return "资讯";
        } else if (uid == 1234567) {
            return "文章（创业万里行）";
        } else {
            return "文章（用户主页）";
        }
    }

    @Override
    public boolean useRxBus() {
        return false;
    }

    @Override
    public int getUId() {
        return uid;
    }
}
